package br.com.hpedroni.gandroidengine.layers;

import java.util.ArrayList;

import android.graphics.Canvas;

public class LayerManager {

	private ArrayList<Layer> layers;

	public LayerManager() {
		layers = new ArrayList<Layer>();
	}

	/**
	 * 
	 * @param layer
	 */
	public void append(Layer layer) {
		layers.add(layer);
	}

	/**
	 * 
	 * @param layer
	 * @param index
	 */
	public void insert(Layer layer, int index) {
		layers.add(index, layer);
	}

	/**
	 * 
	 * @param index
	 * @return
	 */
	public Layer getLayerAt(int index) {
		return layers.get(index);
	}

	/**
	 * 
	 * @param canvas
	 */
	public void draw(Canvas canvas) {
		if (layers.size() > 0) {
			for (Layer layer : layers) {
				if (layer.isVisible()) {
					layer.draw(canvas);
				}
			}
		}
	}

}
